package com.kamistoat.meimeichat.meimeichatclient.kcp;

import com.kamistoat.meimeichat.meimeichatclient.application.UIServiceConnector;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.DatagramChannel;

/**
 * KcpClient端的init。
 * UDP-KCP协议时继承自定义的 UkcpChannel 类
 */
public class KcpNettyClientChannelInitializer extends ChannelInitializer<DatagramChannel> {

    private UIServiceConnector uiServiceConnector;

    public KcpNettyClientChannelInitializer(UIServiceConnector uiServiceConnector) {
        this.uiServiceConnector = uiServiceConnector;
    }

    @Override
    protected void initChannel(DatagramChannel channel) throws Exception {
        channel.pipeline().addLast(new P2PDatagramHandler(this.uiServiceConnector));
    }
}
